﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using MusicSite.Helpers;

[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "log4net", Watch = true)]
namespace MusicSite
{
    public class Global : System.Web.HttpApplication
    {
        private static readonly object SyncRoot = new object();

        protected void Application_Start(object sender, EventArgs e)
        {
            lock (SyncRoot)
            {
                Logger.InitLogger();
                Logger.Log.Debug("Web application started.");
            }
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            lock (SyncRoot)
            {
                Logger.Log.Error(Context.Error.Message, Context.Error);
                Response.Redirect("~/Views/error.aspx", true);
            }
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {
            lock (SyncRoot)
            {
                Logger.Log.Debug("Web application ended.");
            }
        }
    }
}